<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="begin">开始</button>
    <button class="stop">结束</button>
    <script>
        var begin=document.querySelector('.begin');
        var stop=document.querySelector('.stop');
        var time1;
        begin.addEventListener('click',function(){
            console.log('开启定时器');
            time1=setInterval(function(){
                console.log('chijichiji');
            },1000)
        });
        stop.addEventListener('click',function(){
            console.log('结束定时器');
            clearInterval(time1);
        })
    </script>
</body>
</html>